home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2000 #5
/
Amiga Plus CD - 2000 - No. 5.iso
/
Tools
/
Dev
/
Real
/
realprefs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-11-28
|
7KB
|
255 lines
/*
* Source machine generated by GadToolsBox V2.0b
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : Miloslaw Smyk
*/
#define REVISION "40.3beta"
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <string.h>
#include <clib/diskfont_protos.h>
#include <pragmas/exec_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#include <pragmas/gadtools_pragmas.h>
#include <pragmas/graphics_pragmas.h>
#include <pragmas/utility_pragmas.h>
#include <proto/diskfont.h>
#include "wfmhcybergfx_key.h"
#include "realprefs.h"
extern struct KeyBase *KeyBase;
struct Screen *Scr = NULL;
UBYTE *PubScreenName = NULL;
APTR VisualInfo = NULL;
struct Window *RealPrefsWnd = NULL;
struct Gadget *RealPrefsGList = NULL;
struct IntuiMessage RealPrefsMsg;
struct Gadget *RealPrefsGadgets[5];
UWORD RealPrefsLeft = 50;
UWORD RealPrefsTop = 50;
UWORD RealPrefsWidth = 274;
UWORD RealPrefsHeight = 59;
UBYTE *RealPrefsWdt = (UBYTE *)"wfmhcybergfx_r3d.library";
struct TextAttr *Font, Attr;
UWORD FontX, FontY;
UWORD OffX, OffY;
struct TextFont *RealPrefsFont = NULL;
int public;
extern ULONG AboutBox;
UBYTE *Gadget000Labels[] = {
(UBYTE *)"Floyd-Steinberg",
(UBYTE *)"Ordered 4x4",
(UBYTE *)"None",
NULL };
UWORD RealPrefsGTypes[] = {
CYCLE_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
CHECKBOX_KIND
};
struct NewGadget RealPrefsNGad[] = {
101, 5, 160, 13, (UBYTE *)"_Dithering", NULL, GD_Gadget00, PLACETEXT_LEFT, NULL, (APTR)Gadget00Clicked,
13, 41, 77, 13, (UBYTE *)"_Save", NULL, GD_Gadget10, PLACETEXT_IN, NULL, (APTR)Gadget10Clicked,
184, 41, 77, 13, (UBYTE *)"_Cancel", NULL, GD_Gadget20, PLACETEXT_IN, NULL, (APTR)Gadget20Clicked,
98, 41, 77, 13, (UBYTE *)"_Use", NULL, GD_Gadget30, PLACETEXT_IN, NULL, (APTR)Gadget30Clicked,
101, 23, 26, 13, (UBYTE *)"_About box", NULL, GD_Gadget40, PLACETEXT_LEFT, NULL, (APTR)Gadget40Clicked
};
ULONG RealPrefsGTags[] = {
(GTCY_Labels), (ULONG)&Gadget000Labels[ 0 ], (GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (GTCB_Checked), TRUE, (GTCB_Scaled), TRUE, (TAG_DONE)
};
static UWORD ComputeX( UWORD value )
{
return(( UWORD )((( FontX * value ) + 4 ) / 8 ));
}
static UWORD ComputeY( UWORD value )
{
return(( UWORD )((( FontY * value ) + 4 ) / 8 ));
}
static void ComputeFont( UWORD width, UWORD height )
{
Forbid();
Font = &Attr;
Font->ta_Name = (STRPTR)GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name;
Font->ta_YSize = FontY = GfxBase->DefaultFont->tf_YSize;
FontX = GfxBase->DefaultFont->tf_XSize;
Permit();
OffX = Scr->WBorLeft;
OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
if ( width && height ) {
if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
goto UseTopaz;
if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
goto UseTopaz;
}
return;
UseTopaz:
Font->ta_Name = (STRPTR)"topaz.font";
FontX = FontY = Font->ta_YSize = 8;
}
int SetupScreen(struct Screen *scr)
{
if(scr)
{
Scr = scr;
public = FALSE;
}
else
{
public = TRUE;
if ( ! ( Scr = LockPubScreen( PubScreenName )))
return( 1L );
}
ComputeFont( 0, 0 );
if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
return( 2L );
return( 0L );
}
void CloseDownScreen( void )
{
if ( VisualInfo ) {
FreeVisualInfo( VisualInfo );
VisualInfo = NULL;
}
if(Scr && public)
UnlockPubScreen(NULL, Scr);
Scr = NULL;
}
void RealPrefsRender( void )
{
ComputeFont( RealPrefsWidth, RealPrefsHeight );
DrawBevelBox( RealPrefsWnd->RPort, OffX + ComputeX( 0 ),
OffY + ComputeY( 0 ),
ComputeX( 274 ),
ComputeY( 59 ),
GT_VisualInfo, VisualInfo, TAG_DONE );
}
int OpenRealPrefsWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = RealPrefsLeft, wtop = RealPrefsTop, ww, wh;
ComputeFont( RealPrefsWidth, RealPrefsHeight );
ww = ComputeX( RealPrefsWidth );
wh = ComputeY( RealPrefsHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( RealPrefsFont = OpenDiskFont( Font )))
return( 5L );
if ( ! ( g = CreateContext( &RealPrefsGList )))
return( 1L );
for( lc = 0, tc = 0; lc < RealPrefs_CNT; lc++ ) {
CopyMem((char * )&RealPrefsNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
RealPrefsGadgets[ lc ] = g = CreateGadgetA((ULONG)RealPrefsGTypes[ lc ], g, &ng, ( struct TagItem * )&RealPrefsGTags[ tc ] );
while( RealPrefsGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
GT_SetGadgetAttrs(RealPrefsGadgets[0], RealPrefsWnd, NULL, GTCY_Active, KeyBase ? KeyBase->dither_type : DT_NONE);
GT_SetGadgetAttrs(RealPrefsGadgets[4], RealPrefsWnd, NULL, GTCB_Checked, AboutBox);
if ( ! ( RealPrefsWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, CYCLEIDCMP|BUTTONIDCMP|CHECKBOXIDCMP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_CHANGEWINDOW|IDCMP_VANILLAKEY,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE|WFLG_RMBTRAP,
WA_Gadgets, RealPrefsGList,
WA_Title, RealPrefsWdt,
WA_ScreenTitle, "wfmhcybergfx_r3d.library " REVISION " ©1995-97 Miloslaw Smyk (thorgal@amiga.com.pl)",
WA_PubScreen, Scr,
TAG_DONE )))
return( 4L );
GT_RefreshWindow( RealPrefsWnd, NULL );
RealPrefsRender();
return( 0L );
}
void CloseRealPrefsWindow( void )
{
if ( RealPrefsWnd ) {
CloseWindow( RealPrefsWnd );
RealPrefsWnd = NULL;
}
if ( RealPrefsGList ) {
FreeGadgets( RealPrefsGList );
RealPrefsGList = NULL;
}
if ( RealPrefsFont ) {
CloseFont( RealPrefsFont );
RealPrefsFont = NULL;
}
}